<template>
  <div class="viewcontainer" v-if="dataset">
    <el-row class="view-header">
      <el-col :span="22">
        <hi-lquery v-bind="queryPanel" :target="dataset"></hi-lquery>
      </el-col>
    </el-row>
    <el-row class="view-main">
      <el-table
        ref="dataTable"
        :data="dataset.data"
        height="100%"
        style="width: 100%"
        v-loading="dataset.loading"
      >
        <el-table-column type="index" width="50" />
        <el-table-column prop="FSHOPDESC" label="店铺" width="180" />
        <el-table-column prop="FGOODSNUMBER" label="店内编码" width="180" />
        <el-table-column prop="FBARCODE" label="条形码" width="180" />
        <el-table-column prop="FDESC" label="通用名称" width="180" />
        <!-- <el-table-column prop="FBRAND" label="品牌" width="180" /> -->
        <el-table-column prop="FCLASS" label="类别" width="180" />
        <!-- <el-table-column prop="FDRUGCLASS" label="药品分类" width="160" /> -->
        <el-table-column prop="FSPEC" label="规格" width="300">
          <template slot-scope="scope">
            <div class="text-truncate" :title="scope.row.FSPEC">
              {{ scope.row.FSPEC }}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="FAMOUNT" label="数量" width="140" />
        <el-table-column
          prop="FSTORELOWER"
          label="库存下限"
          width="140"
          v-if="curFunc == 'qh'"
        />
        <el-table-column
          prop="FSTOREUPPER"
          label="库存上限"
          width="140"
          v-else
        />
        <el-table-column prop="FUNIT" label="单位" width="140" />
        <el-table-column prop="FPRICE" label="单价" width="140">
          <template slot-scope="scope">
            {{ formatMoney(scope.row.FPRICE) }}
          </template>
        </el-table-column>
        <el-table-column prop="FPROCOMPANY" label="生产厂家" width="260">
          <template slot-scope="scope">
            <div class="text-truncate" :title="scope.row.FPROCOMPANY">
              {{ scope.row.FPROCOMPANY }}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="FMEDICARETYPE" label="医保类别" width="200" />
        <!-- <el-table-column prop="FCREATEDATE" label="创建日期" width="160" /> -->
      </el-table>
    </el-row>
    <el-row class="view-footer pagebar">
      <hi-pagination
        background
        :total="dataset.total"
        :target="dataset"
      ></hi-pagination>
    </el-row>
  </div>
</template>

<script>
import {
  HiPagination,
  HiLquery,
  HiVquery,
  DataSetContainer,
  HiForm,
  utils,
  dataHelper,
} from "hi-ui";
import viewBase from "@/views/base";
import storeQueryCfg from "./dataset";
export default {
  name: "lacklist",
  extends: viewBase,
  components: {
    HiPagination,
    HiLquery,
    HiVquery,
    HiForm,
  },
  data() {
    let datasetCfg = Object.assign({}, storeQueryCfg, {});
    return {
      //数据桥梁
      dataBridge: new Map(),

      detailFormVisible: false,
      dataset: null,
      //数据集配置
      datasetCfg: datasetCfg,
      total: 100,
      //查询面板配置
      queryPanel: {
        columnsTotal: 3,

        fields: [
          {
            // element: "el-input",
            label: "店铺",
            name: "FSHOPDESC",
            element: "hi-select-grid",
            required: true,
            props: {
              selectOption: {
                loading: true,
                multiple: false,
                clearable: true,
                filterable: true,
                "allow-create": true,
                "collapse-tags": true,
              },
              lookup: {
                modelFile: "database/shop/dataset/ShopEntity.xml",
                label: "FDESC",

                tableprops: {
                  "show-header": false,
                  "max-height": 400,
                  white_space_nowrap: true,
                },
                returnFields: {
                  FSHOPDESC: "FDESC",
                  FSHOPDESCID: "FNUMBER",
                },
                columns: [
                  {
                    width: "140",
                    name: "FDESC",
                    label: "通用名称",
                  },
                ],
              },
            },
          },
          {
            element: "el-input",
            label: "店内编码",
            name: "FGOODSNUMBER",
          },
          {
            // element: "el-input",
            label: "通用名称",
            name: "FDESC",
            element: "hi-select-grid",
            props: {
              selectOption: {
                loading: true,
                multiple: false,
                clearable: true,
                filterable: true,
                "allow-create": true,
                "collapse-tags": true,
              },
              lookup: {
                modelFile: "database/drug/dataset/DrugEntity.xml",
                // label: "FDESC",
                // filtername: "FCOMMON",
                filternames: [
                  {
                    name: "FDESC",
                  },
                  {
                    name: "FPINYIN",
                    // operate: "like",
                  },
                  {
                    name: "FJIANPIN",
                  },
                ],
                active: false,
                tableprops: {
                  // border:true,
                  hideRowBorder: true,
                  stripe: true,
                  "show-header": false,
                  //fit:false,
                  size: "mini",
                  "max-height": 400,
                  white_space_nowrap: true,
                },
                returnFields: {
                  FDESC: "FDESC",
                  // FSHOPDESCID: "FNUMBER",
                },
                columns: [
                  {
                    width: "180",
                    name: "FDESC",
                    label: "通用名称",
                  },
                ],
              },
            },
          },
        ],
      },
    };
  },
  model: {
    prop: "value",
    event: "valuechange",
  },
  props: {
    value: {
      type: Object,
    },
  },

  computed: {
    curFunc() {
      //缺货
      if (this.$route.path == "/warning/lack") return "qh";
      else return "jh"; //积货
    },
  },
  watch: {},
  methods: {
    formatMoney(val) {
      return utils.number.format(val, "￥");
    },
    afterquery() {
      this.dataset.load();
    },
  },

  mounted() {
    this.dataset = this.createDataSet(this.datasetCfg);
    this.dataset.on("beginload", (param) => {
      debugger;
      if (!param) {
        param = new dataHelper.queryHelper.Param();
        param.where = new dataHelper.queryHelper.Where();
      }

      if (this.curFunc == "qh") {
        param.where.lteq("FQH", 0);
        param.where.noteq("FQH", 0);
      } else {
        param.where.lteq("FJH", 0);
        param.where.noteq("FJH", 0);
      }
    });
    this.dataset.load();
    //this.$route.path == '/warning/lack'
    this.dataBridge.set(this.dataset, ["dataTable", "detailForm"]);
  },
};
</script>

<style rel="stylesheet/scss" lang="scss" scope></style>
